package com.cat.greedyAlgorithm;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/minimum-swaps-to-make-strings-equal/description/?envType=problem-list-v2&envId=GT3MFwwC
 * @create 2025/10/3 22:20
 * @since JDK17
 */

public class Solution51 {
    public int minimumSwap(String s1, String s2) {
        int[] cnt = new int[2];
        for (int i = 0, n = s1.length(); i < n; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                cnt[s1.charAt(i) % 2]++;
            }
        }
        int ans = cnt[0] + cnt[1];
        if (ans % 2 == 1) {
            return -1;
        }
        return ans / 2 + cnt[0] % 2;
    }
}
